package com.sihan.swvp.service.video;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sihan.swvp.common.CommonUtil;
import com.sihan.swvp.dao.video.VideoSynDao;
import com.sihan.swvp.entity.video.VideoSyn;

@Service
public class VideoSynService {
	
	@Autowired
	private VideoSynDao synDao;
	
	public void addVideosyn(VideoSyn videoSyn){
		System.out.println(videoSyn.getRawpath());
		List<Map> tasks = synDao.getBzidByRwid(videoSyn.getTask_id());
		if(!tasks.isEmpty()){
			videoSyn.setBz_id(CommonUtil.o2int(tasks.get(0).get("bz_id")));
		}
		if(synDao.getvsByRawpath(videoSyn.getRawpath()) > 0){
			synDao.updateVideo(videoSyn);
		}
		else{
			synDao.addVideo(videoSyn);
		}
	}

	
	public List<VideoSyn> getVideo(Map<String,Object> params){
		
		return synDao.getVideo(params);
	}
}
